package enterprise.manage.web.controller;

import com.shenzhoufu.common.utils.crypto.Md5;
import enterprise.manage.security.utils.SecurityUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by IntelliJ IDEA.
 * User: liyong
 * Date: 2010-2-26
 * Time: 14:19:23
 */
public class IndexController extends AbstractController {

    /**
     * 首页
     */
    private static final String LOGIN_VIEW = "forward:/login.aspx";
    private static final String INDEX_VIEW =  "redirect:/frame.aspx";

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request
            , HttpServletResponse response) throws Exception {
       String userId = request.getSession().getAttribute(SecurityUtils.SESSION_USER_ID)== null?"":request.getSession().getAttribute(SecurityUtils.SESSION_USER_ID).toString();
        if(StringUtils.isNotBlank(userId)){
            return new ModelAndView(INDEX_VIEW);
        }
        return new ModelAndView(LOGIN_VIEW);
    }
}